package module
{
	import commons.PipeAwareModuleConstants;
	
	import module.controller.RemoveModuleCommand;
	import module.controller.StartupCommand;
	
	import org.puremvc.as3.multicore.interfaces.IFacade;
	import org.puremvc.as3.multicore.patterns.facade.Facade;

	public class ModuleFacade extends Facade implements IFacade
	{
		public function ModuleFacade(key:String)
		{
			super(key);
		}
		
		public static function getInstance(key:String):ModuleFacade{
			var teste:Array = instanceMap;
			if(instanceMap[key] == null)
				instanceMap[key] = new ModuleFacade(key);
			return instanceMap[key] as ModuleFacade;
		}
		
		override protected function initializeController():void{
			super.initializeController();
			
			registerCommand(ModuleConstants.CMD_STARTUP, StartupCommand);
			registerCommand(PipeAwareModuleConstants.REMOVE_MODULE, RemoveModuleCommand);
		}
		
		public function startup(app:ModuleSample):void{
			sendNotification(ModuleConstants.CMD_STARTUP, app);
		}
		
	}
}